﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Setting.cs" company="DevDigital">
//   DevDigital
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Settings.NET
{
    /// <summary>
    /// Setting information
    /// </summary>
    /// <typeparam name="TValue">The type of the value.</typeparam>
    public class Setting<TValue> : ISetting<TValue>
    {
        /// <summary>
        /// The key
        /// </summary>
        private readonly string key;

        /// <summary>
        /// The value
        /// </summary>
        private readonly TValue value;

        /// <summary>
        /// Flag if the setting is in storage
        /// </summary>
        private readonly bool isInStorage;

        /// <summary>
        /// Initializes a new instance of the <see cref="Setting{TValue}" /> class.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <param name="value">The value.</param>
        /// <param name="isInStorage">if set to <c>true</c> the setting is in storage.</param>
        public Setting(string key, TValue value, bool isInStorage)
        {
            this.key = key;
            this.value = value;
            this.isInStorage = isInStorage;
        }

        /// <summary>
        /// Gets the key.
        /// </summary>
        /// <value>
        /// The key.
        /// </value>
        public string Key
        {
            get
            {
                return this.key;
            }
        }

        /// <summary>
        /// Gets the value.
        /// </summary>
        /// <value>
        /// The value.
        /// </value>
        public TValue Value
        {
            get
            {
                return this.value;
            }
        }

        /// <summary>
        /// Gets a value indicating whether this instance is in storage.
        /// </summary>
        /// <value>
        /// <c>true</c> if this instance is in storage; otherwise, <c>false</c>.
        /// </value>
        public bool IsInStorage
        {
            get
            {
                return this.isInStorage;
            }
        }
    }
}